#!/usr/env/bin python
# -*- coding: utf-8 -*-

# @Time    : 2020-08-24 10:27 上午
# @Author  : yangdy
# @File    : 2020-08-22.2.5480.可以到达所有点的最少点数目
# @Software: PyCharmCE
from tools.my_methods import *


class Solution:
    def findSmallestSetOfVertices(self, n: int, edges: List[List[int]]) -> List[int]:
        ans = []
        in_nums = [0 for i in range(n)]
        for e in edges:
            in_nums[e[1]] += 1
        for i in range(n):
            if in_nums[i] == 0:
                ans.append(i)
        return ans


n = 6
edges = [[0, 1], [0, 2], [2, 5], [3, 4], [4, 2]]
print(e[1] for e in edges)
